package es.ucm.disia.xsdp;

import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;

import es.ucm.disia.xsdp.parser.parserNodo.ParserNodo;
import es.ucm.disia.xsdp.wizard.MainFrame;


/*
 * Clase Principal Xml Syntax Directed Processor
 * */
public class XSDP 
{
	private static ParserNodo parser;
	
	@SuppressWarnings("static-access")
	public XSDP()
	{		
		try 
		{			
			String pathFile= getAbolutePath("prueba.xml");
			ByteArrayInputStream fileStream = getInputStreamFile (pathFile);
			
			this.parser=new ParserNodo(pathFile, fileStream);
			this.parser.parse();														
		} 
		catch (Exception e) 
		{
			e.printStackTrace();
		} 				
	}
	
	private String getAbolutePath(String nameFile)
	{
		return System.getProperty("user.dir") +	File.separator +
									  "files" + File.separator +									  	
									  nameFile;	
	}
	
	private String getFile(String pathFile) throws IOException
	{
		File file=new File(pathFile);
		BufferedReader br= new BufferedReader(new FileReader(pathFile));
		int size=(int) file.length();
		char[] cbuf=new char[size];
		br.read(cbuf);
		br.close();
		return new String(cbuf);		
	}
	
	private ByteArrayInputStream getInputStreamFile(String pathFile) throws IOException
	{
		return new ByteArrayInputStream (getFile(pathFile).getBytes());		
	}
	
	public static void main(String[] args)
	{			
		//new XSDP();				
		//MainFrame wizard=
		new MainFrame();
		//wizard.pack();
	}
}